import 'package:flutter/material.dart';
import 'package:flutterproject/config/route_config.dart';
import 'package:flutterproject/mvvm/base/base_state.dart';
import 'package:flutterproject/page/home/home.dart';
import 'package:flutterproject/page/login_all/login/controller/login_controller.dart';
import 'package:flutterproject/page/login_all/login/widget/phone_pwd.dart';
import 'package:flutterproject/util/extension/extension_util.dart';
import 'package:flutterproject/util/extension/widget_extension.dart';
import 'package:flutterproject/util/margin_padding_util.dart';
import 'package:flutterproject/widget/button_common.dart';
import 'package:flutterproject/widget/text/text_common.dart';
import 'package:get/get.dart';

class LoginPage extends BaseState<LoginController> {
  @override
  LoginController initController() => LoginController();

  @override
  Widget initView(BuildContext context) {
    return Container(
      width: Get.width,
      height: Get.height,
      color: Colors.white,
      padding: MarginPaddingUtil.symmetric(horizontal: 50),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          237.heightBox,
          TextCommon(
            "您好！欢迎登录",
            size: 50.sp,
            color: Color(0xFFFF242429),
            fontWeight: FontWeight.bold,
          ),
          172.heightBox,
          PhonePwdWidget(),
          Spacer(),
          Row(
            children: [
              TextCommon(
                "忘记密码？",
                size: 28.sp,
                color: Color(0xFFEDC88B),
              ).addClickEvent(
                  () => Get.toNamed(RouteName.forgetPwdPage.toString())),
              Spacer(),
              TextCommon(
                "还没有账号？",
                size: 28.sp,
                color: Color(0xFFFF707070),
              ),
              TextCommon(
                "去注册",
                size: 28.sp,
                color: Color(0xFFEDC88B),
              ).addClickEvent(
                  () => Get.toNamed(RouteName.registerPage.toString())),
            ],
          ),
          42.heightBox,
          GetBuilder<LoginController>(
              id: "login",
              builder: (logic) {
                return ButtonCommon(
                  text: "登录",
                  onTap: () => controller.login(),
                  fontSize: 32.sp,
                  fontColor: Colors.white,
                  color: controller.isCorrect
                      ? Color(0xFFEDC88B)
                      : Color(0xFF6E6E6E).withOpacity(0.5),
                  borderRadios: 50,
                  padding: MarginPaddingUtil.only(top: 25, bottom: 29),
                );
              }),
          36.heightBox
        ],
      ),
    );
  }
}
